package com.ruoyi.paper.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.paper.domain.QtTkPaper;
import com.ruoyi.paper.service.IQtTkPaperService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试卷题库中间表Controller
 * 
 * @author zqq
 * @date 2021-11-24
 */
@RestController
@RequestMapping("/paper/paper-tk")
public class QtTkPaperController extends BaseController
{
    @Autowired
    private IQtTkPaperService qtTkPaperService;

    /**
     * 查询试卷题库中间表列表
     */
    @PreAuthorize("@ss.hasPermi('paper:paper-tk:list')")
    @GetMapping("/list")
    public TableDataInfo list(QtTkPaper qtTkPaper)
    {
        startPage();
        List<QtTkPaper> list = qtTkPaperService.selectQtTkPaperList(qtTkPaper);
        return getDataTable(list);
    }

    /**
     * 导出试卷题库中间表列表
     */
    @PreAuthorize("@ss.hasPermi('paper:paper-tk:export')")
    @Log(title = "试卷题库中间表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QtTkPaper qtTkPaper)
    {
        List<QtTkPaper> list = qtTkPaperService.selectQtTkPaperList(qtTkPaper);
        ExcelUtil<QtTkPaper> util = new ExcelUtil<QtTkPaper>(QtTkPaper.class);
        return util.exportExcel(list, "试卷题库中间表数据");
    }

    /**
     * 获取试卷题库中间表详细信息
     */
    @PreAuthorize("@ss.hasPermi('paper:paper-tk:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qtTkPaperService.selectQtTkPaperById(id));
    }

    /**
     * 新增试卷题库中间表
     */
    @PreAuthorize("@ss.hasPermi('paper:paper-tk:add')")
    @Log(title = "试卷题库中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QtTkPaper qtTkPaper)
    {
        return toAjax(qtTkPaperService.insertQtTkPaper(qtTkPaper));
    }

    /**
     * 修改试卷题库中间表
     */
    @PreAuthorize("@ss.hasPermi('paper:paper-tk:edit')")
    @Log(title = "试卷题库中间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QtTkPaper qtTkPaper)
    {
        return toAjax(qtTkPaperService.updateQtTkPaper(qtTkPaper));
    }

    /**
     * 删除试卷题库中间表
     */
    @PreAuthorize("@ss.hasPermi('paper:paper-tk:remove')")
    @Log(title = "试卷题库中间表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qtTkPaperService.deleteQtTkPaperByIds(ids));
    }
}
